package client

import (
	"context"
	"github.com/go-redis/redis/v8"
	"log"
)

func InitRedis(c context.Context, appConfig *Config) *redis.Client {
	RedisClient := redis.NewClient(&redis.Options{
		Addr:     appConfig.Redis.Addr,
		Password: appConfig.Redis.Password,
		DB:       appConfig.Redis.DBNum,
	})
	_, err := RedisClient.Ping(c).Result()
	if err != nil {
		log.Fatalf("redis connect err: %v", err)
	}
	return RedisClient
}
